from LatePenalty.nbgrader import nbgrader_grade
nbgrader late penalty tutorial
This module process the nbgrader generated csv grades files and the output directories, and use canvas api to post grade to students, with late penalty and the messages.
How to use
nbgrader_grade
nbgrader_grade (credentials_fp='', late_exception_fp='', API_URL='https://canvas.ucsd.edu', course_id='', assignment_id=-1, grades_fp='', verbosity=0)
Initialize Canvas Group within a Group Set and its appropriate memberships
Type | Default | Details | |
---|---|---|---|
credentials_fp | str | credential file path. Template of the credentials.json | |
late_exception_fp | str | late exception yaml file path. Template of the late_exception.yaml | |
API_URL | str | https://canvas.ucsd.edu | the domain name of canvas |
course_id | str | Course ID, can be found in the course url | |
assignment_id | int | -1 | assignment id, can be found in the canvas assignment url |
grades_fp | str | nbgrader csv grades exports file path | |
verbosity | int | 0 | Controls the verbosity: 0 = Silent, 1 = print all messages |
= nbgrader_grade("../../../credentials.json",
grade ="../data/late_exception_nbgrader.yaml",
late_exception_fp=45023,
course_id=638121,
assignment_id="../data/grades_example.csv",
grades_fp=1,
verbosity )
Authorization Successful!
Course Set: COGS 108 - Data Science in Practice - Fleischer [SP23]
Getting List of Users... This might take a while...
Users Fetch Complete! The course has 446 users.
Assignment D1 Link!
# take a look at nbgrader csv file
grade.grades.head()
assignment | duedate | timestamp | student_id | last_name | first_name | raw_score | late_submission_penalty | score | max_score | ||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | D1_COGS108_Sp23 | 2023-04-15 07:59:00 | 2023-04-11 00:32:28.990983 | student_0 | NaN | NaN | NaN | 2.0 | 0.0 | 2.0 | 2.0 |
1 | D1_COGS108_Sp23 | 2023-04-15 07:59:00 | 2023-04-17 03:59:02.156619 | student_1 | NaN | NaN | NaN | 2.0 | 0.0 | 2.0 | 2.0 |
2 | D1_COGS108_Sp23 | 2023-04-15 07:59:00 | 2023-04-13 02:03:02.382628 | student_2 | NaN | NaN | NaN | 2.0 | 0.0 | 2.0 | 2.0 |
3 | D1_COGS108_Sp23 | 2023-04-15 07:59:00 | 2023-04-14 01:23:48.922147 | student_3 | NaN | NaN | NaN | 2.0 | 0.0 | 2.0 | 2.0 |
4 | D1_COGS108_Sp23 | 2023-04-15 07:59:00 | 2023-04-12 00:45:49.963719 | student_4 | NaN | NaN | NaN | 2.0 | 0.0 | 2.0 | 2.0 |
Late Submission Exception
with open("../data/late_exception.yaml", "r") as f:
print(f.read())
student_1:
allowed_late_days: 7
reasons: sickness
student_3:
allowed_late_days: 10
reasons: family issue
grade.late_exception
{'student_1': {'allowed_late_days': 7, 'reasons': 'sickness'},
'student_3': {'allowed_late_days': 10, 'reasons': 'family issue'}}
Post Grades
As we can see, the reamining slip day for student 1 and student 3 is 7 and 10 respectively.
nbgrader_grade.post_to_canvas
nbgrader_grade.post_to_canvas (target_assignment:str, passed_assignments:List[str], default_credit:int=7, late_submission_deadline:int=5, post=True)
Post grade to canvas with late penalty.
Type | Default | Details | |
---|---|---|---|
target_assignment | str | target assignment name to grab the late time. Must in the column of nbgrader assignment csv | |
passed_assignments | List | list of passed assignment. Must in the column of nbgrader assignment csv | |
default_credit | int | 7 | default amount of late days calculated, used in FA24 COGS108 |
late_submission_deadline | int | 5 | the maximum amount of late days that we allow. Implements: We don’t accept late submission after 5 days. |
post | bool | True | for testing purposes. Can halt the post operation |
Post grade of assignment D1_COGS108_Sp23
"D1_COGS108_Sp23", [], False) grade.post_to_canvas(
Post Disabled
The message for student_0 is:
D1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 5 Days
Post Disabled
The message for student_1 is:
D1_COGS108_Sp23:
Late Submission: 2 Days Late
Slip Credit Used. No late penalty applied
Remaining Slip Credit: 5 Days
Post Disabled
The message for student_2 is:
D1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 5 Days
Post Disabled
The message for student_3 is:
D1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 10 Days
Post Disabled
The message for student_4 is:
D1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 5 Days
Post grade of assignment A1_COGS108_Sp23
. Before you post it, you will have to link the canvas assignment to A1
with the following command.
nbgrader_grade.link_assignment
nbgrader_grade.link_assignment (assignment_id:int)
Link the target assignment on canvas
Type | Details | |
---|---|---|
assignment_id | int | assignment id, found at the url of assignmnet tab |
Returns | Assignment | target assignment |
= grade.link_assignment(638116) _
Assignment A1 Link!
"A1_COGS108_Sp23", ["D1_COGS108_Sp23"], False) grade.post_to_canvas(
Post Disabled
The message for student_0 is:
A1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 5 Days
Post Disabled
The message for student_1 is:
A1_COGS108_Sp23:
Late Submission: 7 Days Late
Insufficient Slip Credit. 25% late penalty applied
Remaining Slip Credit: 5 Days
Post Disabled
The message for student_2 is:
A1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 5 Days
Post Disabled
The message for student_3 is:
A1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 10 Days
Post Disabled
The message for student_4 is:
A1_COGS108_Sp23:
Submitted intime
Remaining Slip Credit: 5 Days